//
//  TCSdScreenViewController.swift
//  onemeetingmac
//
//  Created by 张衡 on 2020/3/9.
//  Copyright © 2020 onemeeting. All rights reserved.
//

import Foundation

class TCSdScreenViewController: NSViewController {
    
    var source:TRTCScreenCaptureSourceInfo!
    
    override func loadView() {
        let view = NSView.init(frame: NSScreen.main!.frame)
        view.layer?.backgroundColor = NSColor.red.cgColor
        view.wantsLayer = true
        self.view = view
    }
    override func viewDidLoad() {
        super.viewDidLoad()
    }
    
    override func viewWillAppear() {
        super.viewWillAppear()
    }
    
    convenience init(source:TRTCScreenCaptureSourceInfo) {
        self.init()
        self.source = source
        self.setupUI()
        self.loadData()
    }
    
    
    func loadData()  {
        if self.source.type != TRTCScreenCaptureSourceType.unknown {
            if source.type == TRTCScreenCaptureSourceType.window {
                TXLiteManager.shared().selectScreenCaptureTarget(screenSource: source, rect: NSScreen.main!.frame, capturesCursor: true, highlight: true)
            }else if source.type == TRTCScreenCaptureSourceType.screen {
                TXLiteManager.shared().selectScreenCaptureTarget(screenSource: source, rect: CGRect.zero, capturesCursor: true, highlight: true)
            }
            TXLiteManager.shared().startScreenCapture(nil,param:Td.sh().sd.param)
            //TRTCCloud.sharedInstance()?.setSubStreamMixVolume(Td.sh().sd.param.hasSystomAudio ? 100:0)
        }
    }
    
    func setupUI() {
        self.view.addSubview(container)
        container.snp.makeConstraints { (make) in
            make.edges.equalToSuperview()
        }
    }
    
    lazy var container: NSView = {
        let view = NSView()
        return view
    }()
    
    
    
}

